#include  <cstdio>
#include  <stdint.h>
#include  <limits.h>
struct rgb
{
	int16_t	r,g,b;
};

struct rgb targets[16];

int nearest(struct rgb& temp)
{
	int a,b,c,sum,min = INT_MAX, index = -1;

	for( int i = 0 ; i < 16  ; ++i )
	{
		a = targets[i].r - temp.r;
		b = targets[i].g - temp.g;
		c = targets[i].b - temp.b;
		sum = a*a + b*b + c*c;
		if( sum < min )
		{
			min = sum;
			index = i;
		}
	}
	return index;
}

int main(int argc, char *argv[])
{
	struct rgb temp;

	for( int i = 0 ; i < 16  ; ++i )
		scanf("%d %d %d",&targets[i].r, &targets[i].g, &targets[i].b);
	
	scanf("%d %d %d",&temp.r,&temp.g,&temp.b);
	while( temp.r != -1 )
	{
		int i = nearest(temp);
		printf("(%d,%d,%d) maps to (%d,%d,%d)\n",
				temp.r,temp.g,temp.b,targets[i].r,
				targets[i].g,targets[i].b);
		scanf("%d %d %d",&temp.r,&temp.g,&temp.b);
	}
}
